package demoMod.stsconsole.powers;

import demoMod.stsconsole.core.AbstractCreature;
import demoMod.stsconsole.helpers.DamageInfo;
import demoMod.stsconsole.interfaces.InflictSubscriber;
import demoMod.stsconsole.monsters.AbstractMonster;

public class SplitPower extends AbstractPower implements InflictSubscriber {
    public static final String ID = "SplitPower";

    public SplitPower(AbstractCreature owner) {
        super(ID, owner, new int[0]);
    }

    @Override
    public String getUpdatedDescriptions() {
        return this.description;
    }

    @Override
    public void onInflictDamage(DamageInfo info, AbstractCreature target) {
        if (target == this.owner && this.owner.getCurrentHealth() <= this.owner.getMaxHealth() / 2) {
            if (this.owner instanceof AbstractMonster) {
                AbstractMonster monster = (AbstractMonster) this.owner;
                if (monster.getCurrentMove().moveNum != 3) {
                    monster.talk(powerStrings.get(2));
                    monster.changeMove(3, AbstractMonster.Intent.UNKNOWN, monster.monsterStrings.get(3), false, 0, null);
                }
            }
        }
    }
}
